//
//  ThemeFontView.m
//  JW_BasePorject
//
//  Created by JW on 2018/7/4.
//  Copyright © 2018年 JW. All rights reserved.
//

#import "ThemeFontView.h"

#import "FontSizeView.h"
#import "DayNightView.h"
#import "AnswerSetView.h"

@interface ThemeFontView ()

@property (nonatomic, strong) UIView *contentView;


@end

@implementation ThemeFontView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithRed:0.0f green:0.0f blue:0.0f alpha:0.5];
        
        [self setupBasicView];
        
    }
    return self;
}


- (void)setupBasicView{
    
    UITapGestureRecognizer *tapBackGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(removeView)];
    [self addGestureRecognizer:tapBackGesture];
    
    self.contentView = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height-150, SCREEN_WIDTH, 150)];
    self.contentView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.contentView];
    
    
    UITapGestureRecognizer *contentViewTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:nil];
    [self.contentView addGestureRecognizer:contentViewTapGesture];
    
    FontSizeView *sizeView = [[FontSizeView alloc] initWithClickAction:^(UIButton *btn) {
        NSLog(@"%f",btn.titleLabel.font.pointSize);
    }];
    [self.contentView addSubview:sizeView];
    
    DayNightView *DN_view = [[DayNightView alloc] initWithClickAction:^(UIButton *btn) {
        NSLog(@"%@",btn.titleLabel.text);
    }];
    [self.contentView addSubview:DN_view];
    
    AnswerSetView *setView = [[AnswerSetView alloc] initWithFrame:CGRectMake(0, 100, SCREEN_WIDTH, 50)];
    [self.contentView addSubview:setView];
    
}



//显示视图
- (void)showInView:(UIView *)view {
    [view addSubview:self];
    self.contentView.frame = CGRectMake(0, self.frame.size.height, SCREEN_WIDTH, 150);
    
    [UIView animateWithDuration:0.2 animations:^{
        self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
        self.contentView.frame = CGRectMake(0, self.frame.size.height-150, SCREEN_WIDTH, 150);
    }];
    
}

//移除视图
- (void)removeView {
    [UIView animateWithDuration:0.2 animations:^{
        self.backgroundColor = [UIColor clearColor];
        self.contentView.frame = CGRectMake(0, self.frame.size.height, SCREEN_WIDTH, 150);
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}

@end
